-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: improve error for inferSize and Image component #11823
fix: improve error for inferSize and Image component #11823
Conversation
🦋 Changeset detectedLatest commit: 63fcf6f The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Hmm, I'm not sure about this. This function is used for other things than just checking for http paths. I assume that adding this check makes it so it report that width and height are needed? I think it'd perhaps be a better option to add an error for this specific case. |
@Princesseuh no, the check is for showing the user the correct error when if I understand the code correctly, the check that triggers the fetch call is this: so if you think that the check should not be in the |
Yes, I understand the goal. However the |
…inferSize-error-local-image
@Princesseuh I moved the check for |
I think this is better! Ultimately, we'd probably want it done completely differently, but that's something to think through outside of this PR. Thank you! |
Changes
This PR improves the error message a user will see when using
inferSize
in theImage
component when the image is hosted locally instead of remote.The original error message described in the issue (#11821) did not come from Astro, but from
fetch
. Therefore I figured that the check if the image is a remote image or not was incorrect.So I added the check for
isRemotePath
which now triggers the correct error.Testing
I tested this locally by changing an
<img>
in the examples/portfolioabout.astro
page to the<Image>
and addedinferSize
. After the change, the error was the expected error.Docs
No change to the docs needed
closes #11821